package com.zcl.springboot.interceptor;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class InterceptorConfig implements WebMvcConfigurer {
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //需要拦截的路径，/**表示需要拦截所有请求
        String[] addPathPatterns = {"/**"};
        //不需要拦截的请求
        String [] excludePathPaterns={
                "/boot/get",
                "/post",
                "/put",
                "/getUserInfo1"
        };
        registry.addInterceptor(new LogCostInterceptor())
                .addPathPatterns("/*");
               // .excludePathPatterns(excludePathPaterns);
    }
}
